#pragma once

#include "Types.h"
#include "App.h"

namespace My {

class ResourceString : public String {
public:
	ResourceString() : m_ID(0) { }
	ResourceString(const String & s) : String(s), m_ID(0) { }
	ResourceString(const char * ptr) : String(ptr), m_ID(0) { }
	ResourceString(UINT id) : String(GetApp().LoadString(id)), m_ID(id) { }
public:
	ResourceString & operator = (UINT id) { 
		String::operator = (GetApp().LoadString(id));
		m_ID = id;
		return * this;
	}
	bool IsResourceString() const
		{ return m_ID != 0; }
public:
	// compare operations should take into account only resource id if it's not null
	bool operator == (const ResourceString & s) const {
		if (IsResourceString() && s.IsResourceString())
			return m_ID == s.m_ID;
		else
			return static_cast<const String&>(*this) == static_cast<const String&>(s);
	}
	bool operator != (const ResourceString & s) const
		{ return !(*this == s); }
	bool operator < (const ResourceString & s) const {
		if (IsResourceString() && s.IsResourceString())
			return m_ID < s.m_ID;
		else
			return static_cast<const String&>(*this) < static_cast<const String&>(s);
	}
private:
	UINT m_ID;
};

} // My
